﻿using System;
using System.Threading;
using System.Xml;
using Ro.AssistFunction.BackNodeInfo;
using Ro.AssistFunction.OutputManage;
using Ro.Common.RoInterface.RoWebAction;
using Ro.Common.RoInterface.UserType;

namespace Ro.DriverEvent.WebAction
{
    public class WebSleep : IWebSleepFunc
    {
        /// <summary>
        /// 强制等待
        /// </summary>
        /// <param name="sigNode">强制等待Sleep</param>
        /// <returns>返回是否完成</returns>
        public WebActionResult Sleep(XmlNode sigNode)
        {
            //返回值
            ExtractNeedInfo extractNeedInfo = new ExtractNeedInfo();

            //提取时间
            int timeout = Convert.ToInt32(extractNeedInfo.ExtractAttributeValue(sigNode, "web:Seconds"));
            Thread.Sleep(timeout * 1000);

            //提取信息
            string msg = extractNeedInfo.ExtractAttributeValue(sigNode, "web:Message");
            WebActionResult back = BackActionResult.BackWebResult(true, "未使用", "程序Sleep时间： " + timeout + "秒，提示信息： " + msg);
            return back;
        }
    }
}